import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options


class BaseTestCase(unittest.TestCase):
    kitchen_caps = dict(
        platformName='Android',  # 平台类型
        automationName='uiautomator2',  # 驱动类型
        deviceName='7f7e582d',  # 设备名称
        appPackage='com.xiachufang',  # 被测app包名称
        appActivity='.startpage.ui.StartPageActivity',  # 被测app主activity
        noReset=True,
        forceAppLaunch=True,
        shouldTerminateApp=True
    )

    appium_server_url = 'http://127.0.0.1:4723'


    def setUp(self):
        self.driver = webdriver.Remote(self.appium_server_url,
                                       options=UiAutomator2Options().load_capabilities(self.kitchen_caps))

    def tearDown(self):
        if self.driver:
            self.driver.quit()